home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / playre1a / playresw.bas < prev    next >
BASIC Source File  |  1999-09-19  |  2KB  |  45 lines

  1. Attribute VB_Name = "modResWav"
  2. 'for comments please e-mail me at o_pereira@hotmail.com
  3. 'playing a wav using a res file for "vb6 only"
  4. 'the sndPlaySound function is expecting a string
  5. 'for the location & name of the wave so since the wave
  6. 'is in a res file
  7. 'the LoadResData command will load a specified resource
  8. 'and return a byte array[a number from 1-255]
  9. 'of the information that is why you declare  the
  10. 'Global SoundArray() As Byte to hold the array being returned
  11. 'then you have to change the "ByVal lpszSoundName As String"
  12. 'to "lpszSoundName As Byte" making the function return Byte type of data
  13.  
  14. 'this is the declaration found in apiViewer
  15. 'Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
  16.  
  17. 'changed declaration
  18. Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (lpszSoundName As Byte, ByVal uFlags As Long) As Long
  19.  
  20. 'sndPlaySound  flag values for uFlags parameter
  21. Public Const SND_ASYNC = &H1
  22. Public Const SND_NODEFAULT = &H2
  23. Public Const SND_MEMORY = &H4
  24.  
  25. Private SoundArray() As Byte
  26.  
  27. Public Sub PlayResWav(bResId As Byte, sFormat As String)
  28.  
  29.   'this is how loadresdata works
  30.   'LoadResData(index,format)
  31.   'index = Integer specifying the ID of
  32.   'the resource to be loaded within the resource file
  33.   'format = "Type of resource to be loaded" but since its a
  34.   'wave it would be the name type for this case "CUSTOM"
  35.   'you can rename it if you like
  36.   'to make your own resource files use the VB recource editor
  37.   'in your Add-Ins
  38.   'for more information on LoadResData or VB Resource Editor
  39.   'look in your help
  40.   
  41.   SoundArray = LoadResData(bResId, sFormat)
  42.   sndPlaySound SoundArray(0), SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY
  43.  
  44. End Sub
  45.